package com.ruoyi.project.WebMoudle.WxUser.service.impl;

import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.WebMoudle.WxUser.mapper.WxUserMapper;
import com.ruoyi.project.WebMoudle.WxUser.domain.WxUser;
import com.ruoyi.project.WebMoudle.WxUser.service.IWxUserService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 微信用户Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-06-22
 */
@Service
public class WxUserServiceImpl implements IWxUserService 
{
    @Autowired
    private WxUserMapper wxUserMapper;

    /**
     * 查询微信用户
     * 
     * @param id 微信用户ID
     * @return 微信用户
     */
    @Override
    public WxUser selectWxUserById(Long id)
    {
        return wxUserMapper.selectWxUserById(id);
    }

    /**
     * 查询微信用户列表
     * 
     * @param wxUser 微信用户
     * @return 微信用户
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<WxUser> selectWxUserList(WxUser wxUser)
    {
        return wxUserMapper.selectWxUserList(wxUser);
    }

    /**
     * 新增微信用户
     * 
     * @param wxUser 微信用户
     * @return 结果
     */
    @Override
    public int insertWxUser(WxUser wxUser)
    {
        wxUser.setCreateTime(DateUtils.getNowDate());
        return wxUserMapper.insertWxUser(wxUser);
    }

    /**
     * 修改微信用户
     * 
     * @param wxUser 微信用户
     * @return 结果
     */
    @Override
    public int updateWxUser(WxUser wxUser)
    {
        wxUser.setUpdateTime(DateUtils.getNowDate());
        return wxUserMapper.updateWxUser(wxUser);
    }

    /**
     * 删除微信用户对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWxUserByIds(String ids)
    {
        return wxUserMapper.deleteWxUserByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除微信用户信息
     * 
     * @param id 微信用户ID
     * @return 结果
     */
    @Override
    public int deleteWxUserById(Long id)
    {
        return wxUserMapper.deleteWxUserById(id);
    }


    /**
     * 根据openid查询微信用户
     * @return
     */
    @Override
    public WxUser selectUserByOpId(String openid) {
        return wxUserMapper.selectUserByOpId(openid);
    }

    /**
     * 根据手机号查询微信用户
     * @param phonenumber
     * @return
     */
    @Override
    public Integer selectWxUserByPhone(String phonenumber) {
        return wxUserMapper.selectWxUserByPhone(phonenumber);
    }
    /*查询所有的会员id集合*/
    @Override
    public List<Long> selectWxUserIds() {
        return wxUserMapper.selectWxUserIds();
    }

    @Override
    public List<WxUser> queryVipList(Long shopId) {
        return wxUserMapper.queryVipList(shopId);
    }

    @Override
    public int selectVipCount(Long shopId) {
        return wxUserMapper.selectVipCount(shopId);
    }

    @Override
    public WxUser queryByPhone(String phoneNum) {
        return wxUserMapper.queryByPhone(phoneNum);
    }

    @Override
    public String queryUserMoneySum() {
        return wxUserMapper.queryUserMoneySum();
    }

    @Override
    public String queryUserGradeSum() {
        return wxUserMapper.queryUserGradeSum();
    }
    /*<!--清除归属特定的商家-->*/
    @Override
    public int cleanShopId(Long shopId) {
        return wxUserMapper.cleanShopId(shopId);
    }

    @Override
    public int changeTerrace(Long wxUserId) {
        return wxUserMapper.changeTerrace(wxUserId);
    }

    @Override
    public int changeBelongShop(Long wxUserId, Long shopId) {
        return wxUserMapper.changeBelongShop(wxUserId,shopId);
    }

    @Override
    public int setPayNumber(Long wxUserId, String payNumber) {
        return wxUserMapper.setPayNumber(wxUserId,payNumber);
    }

    @Override
    public WxUser selectUserMoneyById(Long wxUserId) {
        return wxUserMapper.selectUserMoneyById(wxUserId);
    }

    @Override
    public int toAddJF(Long wxUserId, Integer jfNum) {
        return wxUserMapper.toAddJF(wxUserId,jfNum);
    }
}
